package com.victualler.core.config.img.repository;

import com.victualler.core.base.repository.BaseRepository;
import com.victualler.core.config.img.entity.ImageItemDao;
import com.victualler.core.config.img.dto.ImageGroupDto;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @Author: Guoshichang
 * @Date: Create in 11:49 2018/4/6
 * @Discription:    数据库操作对象
 */
public interface ImageItemRepository extends BaseRepository<ImageItemDao,Long> {
    @Query("select new com.victualler.core.config.img.dto.ImageGroupDto(img.filePath,count(img.id)) from ImageItemDao img group by img.filePath")
    public List<ImageGroupDto> getFilePathGroup();
    @Query("select img from ImageItemDao img where img.filePath=:fp")
    public List<ImageItemDao> findByFilePath(@Param("fp")String filePath);

    public List<ImageItemDao> findByImageDirId(Long imageDirId);
}
